package net.seehealth.healthpad.application.adapter;

import java.util.ArrayList;
import java.util.List;

import net.seehealth.healthpad.ui.view.MainListItemView;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

public class MainListAdapter extends BaseAdapter {
	
	/** 当前上下文 */
	private Context mContext;
	
	/** 时间集合*/
	private List<List<String>> mValues;
	
	/** 模块标识 **/
	private int type;

	/**
	 * 构造方法
	 * @param context 当前上下文
	 */
	public MainListAdapter(Context context, int type){
		mContext = context;
		this.type = type;
		mValues = new ArrayList<List<String>>();
	}

	public void setData(List<List<String>> values){
		mValues.clear();
		mValues.addAll(values);
	}
	
	@Override
	public int getCount() {
		return mValues.size();
	}

	@Override
	public Object getItem(int position) {
		return mValues.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		
		if (convertView == null) {
			convertView = new MainListItemView(mContext, type);
		}
		
		((MainListItemView) convertView).updateView(mValues.get(position), position);
		
		return convertView;
	}

}
